<%# Copyright 2009 Swansea University

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
%>


<% title "Projects by Supervisor" %>
<%= render(:partial => "navigation") %>

<% content_for :head do %>
  <script type="text/javascript">
    $(document).ready(function() {
      $('.accordian .content').hide();
      $('.accordian .head').click(function() {
        $(this).next().toggle('slow');
        return false;
      }).next().hide();
    });
  </script>
<% end %>


<p>Note that although each member of staff has been asked to provide four or five projects, staff loading
  considerations may mean that not all advertised projects will actually be available.
  For example, some very popular projects/supervisors
may be eliminated in the first allocation round once staff loading limits are reached.</p>

<p>Click on the supervisor's name to see his or her projects.</p>

<% if @supervisors.blank? %>
  <p>No projects to display.</p>
<%else%>
  <% @supervisors.each do |supervisor| %>
    <%  projects = Project.find_all_by_created_by(supervisor) %>
    <% unless projects.size == 0 %>
      <div class="accordian">
        <h3 class="head"
            id="<%= supervisor.id %>"
            title="<%= supervisor.id %>: <%= supervisor.name %>">
          <%= supervisor.name %>
        </h3>
        <div class="content">
          <p><em>Contact email</em>: <a href="mailto:<%= supervisor.email %>"><%= supervisor.email %></a>.<br />
          <em>Research centre</em>: <%= supervisor.supervisor.research_centre.title %></p>
          <table>
            <thead>
              <tr>
                <th>Number</th><th>Title</th>
              </tr>
            </thead>
            <tbody>
              <%  projects.each do |project| %>
                <tr class="<%=  cycle('odd', 'even') %>">
                  <td>
                    <%= project.id -%>
                  </td>
                  <td>
                    <%= link_to project.title, project %>
                  </td>
                </tr>
              <%  end %>
            </tbody>
          </table>
        </div>
      </div>
    <% end %>
  <% end %>
<%end%>
